<?php

use App\Http\Controllers\AttachmentController;
use App\Http\Controllers\EloquentController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

Route::get('/', function () {
    return redirect(admin_route(''));
});

// 一对一关系
Route::prefix('one-to-one')->group(function () {
    Route::get('forward-one-to-one-info', [EloquentController::class, 'forwardOneToOneInfo']);
    Route::get('reverse-one-to-one-info', [EloquentController::class, 'reverseOneToOneInfo']);
    Route::get('belongsto-one-to-one-info', [EloquentController::class, 'belongsToByObject']);
});

// 一对多关系
Route::prefix('one-to-many')->group(function () {
    Route::get('forward-one-to-many-info', [EloquentController::class, 'forwardOneToManyInfo']);
    Route::get('reverse-one-to-many-info', [EloquentController::class, 'reverseOneToManyInfo']);
    Route::get('belongsto-one-to-many-info', [EloquentController::class, 'belongsToByObject']);
    Route::get('hasone-one-to-many-info', [EloquentController::class, 'hasOneOfMany']);
});

// 远程一对一关系
Route::prefix('remote-one-to-one')->group(function () {
    Route::get('forward-one-to-one-info', [EloquentController::class, 'forwardRemoteOneToOneInfo']);
});

// 远程一对多关系
Route::prefix('remote-one-to-many')->group(function () {
    Route::get('forward-one-to-many-info', [EloquentController::class, 'forwardRemoteOneToManyInfo']);
});

// 多堆多
Route::prefix('many-to-many')->group(function () {
    Route::get('forward-many-to-many-info', [EloquentController::class, 'forwardManyToManyInfo']);
    Route::get('reverse-many-to-many-info', [EloquentController::class, 'reverseManyToManyInfo']);
});

// 附件图片
Route::resource('attachments', AttachmentController::class);
